
package com.shangsi.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.shangsi.feignservice.fallback.PaymentFeignService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author dzd
 * @date 2021-12-16
 */
@RestController
public class OrderControllerSentinel {

    @Resource
    private PaymentFeignService paymentFeignService;

    @RequestMapping("consumer/fallback/{id}")
    //exceptionsToIgnore 忽略异常
    @SentinelResource(value = "fallback",fallback = "",exceptionsToIgnore =IllegalArgumentException.class)
    public String order(@PathVariable("id") Integer id){
        String forObject = paymentFeignService.getPayment(id);
        System.out.println(forObject);
        return forObject;
    }

    public String fallback(){
        return "黑黑恶黑黑恶失败了";
    }
}
